<template>
  <!-- 云仓礼包商品订单不支持退换货以及申请售后   is_yuncang_gift 0 非云仓礼包订单 1 云仓礼包订单-->
  <div class="actions">
    <template v-if="detail.order_ly == 10"></template>
    <!-- x+1 商品仅显示 支付，确认收货，下单回执按钮 start -->
    <template v-else-if="detail.is_chaining_show">
      <div class="bottom-btn">
        <div class="bottom-btn-box">
          <van-button round
            href="javascript:;"
            class="btn no-border"
            v-if="(detail.status == '0') || (detail.is_presale == 1 && detail.status == 1 && detail.presale_status != 2 && detail.two_status == '未完成') && !detailAll.notime_pay && detailAll.is_dz_one==1"
            @click="clickPay(detail)">去支付</van-button>
              <template v-if="detail.status == 2 && detail.is_dhs_virtual != 1 && detailAll.is_dz_one == 1">
              <!--定制：江西赣中旅【自提订单确认收货需门店后台操作，或订单到期自动确认收货，买家不能自己选择确认收货】start-->
              <van-button round v-if="(detailAll.is_confirm_receipt != 1 || detail.status_name != '等待买家自提') && !dzData.jxgzl_dz && detail.status_name != '等待拼团成功' && detail.not_real_confirm!=1"
                href="javascript:;"
                class="btn no-border"
                @click="showPop()">确认收货</van-button>
              <!--定制：江西赣中旅【自提订单确认收货需门店后台操作，或订单到期自动确认收货，买家不能自己选择确认收货】end-->
            </template>
          <van-button class="btn border" round v-if="detail.status == 1 || detail.status == 2 || detail.status == 3" @click="toReceiptOrder">下单回执</van-button>
        </div>
      </div>
      </template>
      <!-- x+1 商品仅显示 支付，确认收货，下单回执按钮 end -->
      <template v-else>
    <div class="bottom-btn">
      <div class="bottom-btn-box" v-if="detail.status == 2 && detail.is_dhs_virtual != 1 && detailAll.is_dz_one == 1 && detailAll.is_yuncang_gift == 0">
        <!-- 退换货 -->
        <div class="inline-block" v-if="detailAll.has_duodian && detailAll.is_duodian_model == 1 && detailAll.Apply_for_after_sale != 1 && detail.is_yun_ji!=1">
          <!--     十人团定制 隐藏退货按钮     -->
          <van-button round hairline v-if="detailAll.is_allow_return == 1 && !detailAll.istendz"
            @click="getRefundingUrl(2,true)"
            class="btn refunding-btn"><img src="https://img.wifenxiao.com/h5-wfx/images/item/detail/return_icon.png" alt="" srcset="">退货</van-button>
          <van-button round hairline v-if="detailAll.is_allow_exchange == 1"
            @click="getRefundingUrl(1,true)"
            class="btn refunding-btn"><img src="https://img.wifenxiao.com/h5-wfx/images/item/detail/exchange_icon.png" alt="" srcset="">换货</van-button>
        </div>
        <div class="inline-block" v-else-if="detailAll.Apply_for_after_sale != 1 && detail.is_yun_ji!=1">
          <!--     十人团定制 隐藏退货按钮     -->
          <van-button round hairline v-if="detailAll.is_allow_return == 1 && !detailAll.istendz"
            @click="getRefundingUrl(2)"
                        class="btn refunding-btn"><img src="https://img.wifenxiao.com/h5-wfx/images/item/detail/return_icon.png" alt="" srcset="">退货</van-button>
          <van-button round hairline v-if="detailAll.is_allow_exchange == 1"
            @click="getRefundingUrl(1)"
            class="btn refunding-btn"><img src="https://img.wifenxiao.com/h5-wfx/images/item/detail/exchange_icon.png" alt="" srcset="">换货</van-button>
        </div>
        <van-button round href="javascript:;"
          class="btn no-border afterSale"
          v-else-if="detailAll.Apply_for_after_sale == 1 && detailAll.is_yuncang_gift == 0"
          @click="afterSale(detail.order_id)">申请售后</van-button>
      </div>
      <div class="bottom-btn-box" v-if="detail.pay_type != 10">
        <van-button class="btn border" round @click="handleClickOpenAddress" v-if="detail.client_edit_order_address && detail.client_edit_order_address != 0 ">修改地址</van-button>
        <van-button class="btn border" round v-if="detail.status == 1 || detail.status == 2 || detail.status == 3" @click="toReceiptOrder">下单回执</van-button>
        <!-- TODO 小程序暂时不展示原价分享，后期增加 -->
        <van-button round v-if=" detail.status != '0' && detail.status != '5' && detail.status != '6' && detailAll.is_dz_one == 1 && detailAll.is_price_share_title == 1"
          @click="toCommentList('price')"
          class="btn no-border share-price">原价分享</van-button>
        <template v-if="detailAll.is_need_consultation==1">
          <van-button round hairline class="btn J_pay white-btn" v-if="detail.status == 0 && detail.consultation_status < 2" @click="jumpConsulationUrl(detail.order_id)">去问诊</van-button>
          <van-button round hairline class="btn J_pay white-btn" v-else-if="detail.status==0 && detail.consultation_status == 2" @click="clickPay(detail)">付款</van-button>
          <van-button round hairline class="btn J_pay white-btn" v-else-if="detail.status > 0 && detail.consultation_status == 2" @click="getResultUrl(detail.order_id)">处方笺</van-button>
        </template>
        <!-- 处方药 问诊成功才可以付款 -->
        <template v-if="!detail.consultation_status">
        <van-button round
          href="javascript:;"
          class="btn no-border"
          v-if="(detail.status == '0') || (detail.is_presale == 1 && detail.status == 1 && detail.presale_status != 2 && detail.two_status == '未完成') && !detailAll.notime_pay && detailAll.is_dz_one==1"
          @click="clickPay(detail)">去支付</van-button>
        </template>
        <div class="inline-block" v-if="detail.status == 2 && detail.is_dhs_virtual != 1 && detailAll.is_dz_one == 1">
          <!--定制：江西赣中旅【自提订单确认收货需门店后台操作，或订单到期自动确认收货，买家不能自己选择确认收货】start-->
          <van-button round v-if="(detailAll.is_confirm_receipt != 1 || detail.status_name != '等待买家自提') && !dzData.jxgzl_dz && detail.status_name != '等待拼团成功' && detail.not_real_confirm!=1"
            href="javascript:;"
            class="btn no-border"
            @click="showPop()">确认收货</van-button>
          <!--定制：江西赣中旅【自提订单确认收货需门店后台操作，或订单到期自动确认收货，买家不能自己选择确认收货】end-->
        </div>
        <div class="inline-block" v-else-if="detail.status == '1' || detail.status == '2' || (detail.status == '3' && detailAll.is_dz_one==1)">
          <van-button round v-if="(detail.status == '3' && detailAll.is_dz_one==1) && detail.need_comment && detail.store_gathering_id == 0 && detailAll.is_comment == 1"
            @click="toCommentList('evaluate')"
            class="btn no-border evaluate-btn">评价晒单</van-button>
          <van-button round v-if="detail.need_comment && detail.store_gathering_id == 0"
            @click="toCommentList('share')"
            class="btn no-border evaluate-btn">我要晒单</van-button>
          <van-button round v-if="(detail.status == '3' && detailAll.is_dz_one==1) && detailAll.after_sale_tel && detailAll.is_yuncang_gift == 0"
            @click="wxPhoneCall(detailAll.after_sale_tel)"
            class="btn no-border">联系售后</van-button>
        </div>
        <div class="inline-block" v-else-if="(detailAll.is_refund_config == 1 && detail.is_dhs_delivery != 1 && detail.is_cycle != 1 && detail.status == 1 && detail.is_presale !=1 && detail.pay_type != 3 && isPrizeGroup) || (detail.status == 2 && detail.is_dhs_virtual == 1)">
          <!-- 定制 莱特妮丝 单品不可退款和多商品全部不可退款的情况下 不显示退款按钮 start -->
          <template v-if="(detailAll.item_refundable_dz && detailAll.is_show_refundable_btn === 1) || !detailAll.item_refundable_dz">
          <van-button round v-if="detailAll.is_allow_return == 1 && detailAll.is_dz_one == 1 && !detail.delivery_fn && detail.is_yun_ji!=1 && detailAll.is_yuncang_gift == 0 && !detailAll.istendz"
            @click="getRefundingUrl(2)"
            class="btn no-border">退款</van-button>
          </template>
        </div>
      </div>
    </div>
    <!-- <van-dialog class="common-confirm"
                v-model="showConfirm"
                title="确认收货？"
                show-cancel-button
                @confirm="binding"></van-dialog> -->

    <pay-password :showPwd="showPwd" @closePwd="closePwd" @payPwdCallback="payPwdCallback"></pay-password>
    <van-popup v-model="showPayPop" class="pay-box" position="top" :style="{ height: '100%' }">
      <!-- <tx-pop @closePop="closeCashPop" :dzData="dzData" :cashPopData="cashPopData"></tx-pop> -->
      <more-payment :itemIds="itemIds" :isJhPay="true" :isTlfzPay="isTlfzPay" :isHffzPay="true"  @closePayPop="closePayPop" @payCallback="payCallback" :payPopData="payPopData"></more-payment>
    </van-popup>

    <div>
      <send-code-payment ref="sendCodePayment"  />
    </div>
    </template>
    <address-dialog :visible.sync="addressVisible" :orderEdit="true" :now_address_id="detailAll.detail.address_id" @selectAddress="selectAddress"></address-dialog>
  </div>
</template>

<script>
import Vue from 'vue'
/* eslint-disable */
import PayPassword from '@/components/PayPassword/index'
import MorePayment from '@/components/MorePayment/index'
import { isWeixinCient } from '@/utils/validate'
import { openPage } from '@/utils/utils'
import { userConfirm ,payUrl} from '@/api/order/order.js'
import { wlUserInfo } from '@/api/login'
import smllpay from '@/smallapp/smallpay'
import sendCodePayment from  '../../buy/components/sendCodePayment/index'
import { medicineUrl, medicineResultUrl } from '@/api/public/index.js'
import Store from '@/utils/store'
import small from '@/smallapp/small'
import addressDialog from '@/components/addressDialog'

export default Vue.extend({
  props: {
    detailAll: {
      type: Object,
      default: () => {
        return {}
      }
    },
    dzData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    queryData: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  components: {
    PayPassword,
    MorePayment,
    sendCodePayment,
    addressDialog
  },
  data() {
    return {
      showConfirm: false, //确认收货
      showPwd: false, // 支付密码弹框是否显示
      showPayPop: false, // 付款弹窗

      payPopData: {},
      submitData: {},
      must_pay_password: '',
      popup_show: '',
      isPrizeGroup: true, // 抽奖团是否拼团成功并且已中奖
      isTlfzPay: true,
      remark: -1,
      hfAppId: '',
      itemIds: [], // 商品id
      addressVisible: false,
    }
  },
  methods: {
    // 打开地址弹窗
    handleClickOpenAddress() {
      this.addressVisible = true
    },
    // 选择地址
    selectAddress(data) {
      this.$Bus.$emit('curEditAddress', data)
    },
    Jump(url, data) {
      this.$JumpPath(this, url, data)
    },
    // TODO 微分销与小程序差别：拨打电话
    wxPhoneCall(phone) {
      wx.makePhoneCall({
        phoneNumber: phone // 仅为示例，并非真实的电话号码
      })
    },
    // 问诊
    // 处方药定制 跳转h5问诊
    jumpConsulationUrl(order_id) {
      // console.log('dzJumpMedicinedzJumpMedicine')
      const data = {
        order_id: order_id
      }
      medicineUrl(data).then(res => {
        if (res.status == 1) {
          // console.log('awe', res.data)
          // window.location.href = res.data
          let url = res.data
          // console.log('urlurl:', url)
          Store.saveLocal('webSrc', url)
          this.$JumpName(this, 'webView', {title: '处方笺'})
        }
      })
    },
    // 获取处方药
    getResultUrl(order_id) {
      const data = {
        order_id: order_id
      }
      medicineResultUrl(data).then(res => {
        if (res.status == 1) {
          // console.log('awe-medicineResultUrl', res.data)
          // window.location.href = res.data
          let url = res.data
          // console.log('urlurl:', url)
          Store.saveLocal('webSrc', url)
          this.$JumpName(this, 'webView', {title: '处方笺'})
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 跳转
    toCommentList(type) {
      let name = 'commentList'
      let query = {
        type
      }
      // 处理当从订单详情原价分享只有一个商品的时候直接跳转分享晒单页面不走中间页，否则走原逻辑不变
      const itemData = this.detailAll.detail.item
      const itemLen = itemData.length
      const listLen = itemData[0].list.length
      if (type == 'price' && itemLen == 1 && listLen == 1) { // 只判断是原价分享并且只有不存在供应商的时候
        name = 'shareOrder'
        query.itemId = itemData[0].list[0].order_item_id
      } else {
        query.orderId = this.detailAll.detail.order_id
      }
      this.$JumpName(this, name, query)
    },
    // order_comment
    toOrderComment() {
      const url = `/Order/order_comment/id/${this.detail.order_id}/share/1`
      return url
    },
    toReceiptOrder() {
      this.$JumpName(this, "receiptOrder", this.queryData);
    },
    // 退换货链接 退款和退货2，
    getRefundingUrl(type, supid) {
      if(supid){
        this.$JumpName(this,'refunding',{id:this.detailAll.detail.order_id,type:type,supid:this.detailAll.new_supplier_id || 0})
      }else{
        this.$JumpName(this,'refunding',{id:this.detailAll.detail.order_id,type:type})
      }
    },
    // 确认收货弹框
    showPop() {
      wx.showModal({
        content: '确认收货？',
        success: (res) => {
          if (res.confirm) {
            this.binding()
          }
        }
      })
    },
    // 确认收货
    binding() {
      let that = this
      this.$loadingWrap.show()
      // console.log('this.detail', that.detail.is_wechat_confirm_receipt, that.detail.transaction_id)
      if (that.detail.is_wechat_confirm_receipt && that.detail.transaction_id) {
        if (wx.openBusinessView) {
          wx.openBusinessView({
            businessType: 'weappOrderConfirm',
            extraData: {
              transaction_id: that.detail.transaction_id
            },
            success(res) {
              // console.log('详情success', res)
              //dosomething
              that.userConfirmBind()
            },
            fail(errormsg) {
              // console.log('详情fail', errormsg)
              that.$Error(errormsg)
              //dosomething
            }
          });
        } else {
          //引导用户升级微信版本
          that.$Error('升级到最新的微信版本')
        }
      } else {
        that.userConfirmBind()
      }
    },
    userConfirmBind() {
      this.$loadingWrap.show()
      userConfirm({ order_id: this.detail.order_id }).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          this.$Error('操作成功')
        } else {
          this.$Error(res.msg)
        }
        // TODO 小程序使用广播 广播名称最好和页面名称一致 避免和其它页面广播名称重复
          window.$$publish('btnInfoRefresh', true)
      })
    },
    // 申请售后
    afterSale(id) {
      this.$loadingWrap.show()
      setTimeout(() => {
        this.$loadingWrap.close()
      }, 10000)
      const Fenbot_cid = Store.fetchLocal('Fenbot_cid')
      // console.log('售后' + Fenbot_cid)

      wlUserInfo({ id }).then(res => {
        const that = this
        if (!res.data.flag) {
          return false
        }
        // 微聊jsapi接口 - 会员信息&最近一条订单信息
        window['_FENBOT_API'] && window._FENBOT_API('apiInfo', Fenbot_cid, res.data)
        setTimeout(function() {
          that.$loadingWrap.close()
          if ($('.FENBOT-CHATBTN-BTN').length > 1) {
            // console.log(1)
            $('.wl_box .FENBOT-CHATBTN-BTN').click()
          } else {
            // console.log(2)
            $('.FENBOT-CHATBTN-BTN').click()
          }
        }, 1000)
      })
    },
    // 点击付款
    clickPay(item) {
      // console.log(item)
      const payType = item.pay_type
      const peerType = item.peer_type
      if (payType == 5) {
        window.location.href = '/Paypal/doPaypal/order_id/' + item.order_id
        return false
      } else if (payType == 7 && peerType == 2) {
        // window.location.href = '/PeerPay/peer_detail/id/' + item.order_id
        this.$JumpName(this,'peer-pay-detail', { id: item.order_id })
        return false
      }
      this.payPopData.payment = item.payment
      this.payPopData.order_id = item.order_id

      this.showPayPop = true
    },
    // 关闭付款弹窗
    closePayPop() {
      this.showPayPop = false
    },
    // 点击确定付款，付款请求
    payCallback(submitData) {
      this.submitData = submitData
      // console.log(submitData)
      if (submitData.yeChecked && submitData.tlfz_deposit) {
        this.$refs.sendCodePayment.handleShow({
          order_id: submitData.order_id,
          tlfz_pay_type: 4
        })
        return
      }
      const payType = submitData.type
      const order_id = submitData.order_id
      const money_type = submitData.moneyType
      const payment_type = submitData.payment_type
      const popup_show = this.popup_show
      const payment = this.payPopData.payment
      const global_alipay_currency = submitData.global_alipay_currency
      const hantepay = submitData.hantepay
      const tlfz_pay_type = submitData.tlfz_pay_type

      // 是否强制使用支付密码
      if (this.must_pay_password == 1) {
        if (money_type == 2 && payment > 0) {
          this.$Error('请先去会员中心的修改资料里设置支付密码!')
        } else {
          const params = { hantepay: hantepay, global_alipay_currency: global_alipay_currency, pay_type: payType, order_id: order_id, money_type: money_type, payment_type: payment_type,tlfz_pay_type: tlfz_pay_type }
          this.$loadingWrap.show()
          /* setTimeout(() => {
            this.$loadingWrap.close()
          }, 10000) */
          if (payType == 34) {
            params.adapay_pay_type = submitData.adapay_pay_type
          }
          payUrl(params).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              // TODO 小程序支付处理
              if (res.data && res.data.jsApiParameters) {
                if (payType == 2 || payType == 19 || (payType == 26 && !res.data.is_mini_vsp) || payType == 29 || payType == 48) {
                  smllpay.wxOrderPay(res.data.jsApiParameters)
                } else if (payType == 26 && res.data.is_mini_vsp) {
                  this.Jump('/buyTonglianWait',{ order_id, pay_type: 1 })
                } else if (payType == 34) {
                  if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
                    const jsApiParameters = typeof res.data.jsApiParameters == 'object' ? res.data.jsApiParameters: JSON.parse(res.data.jsApiParameters)
                    this.hfAppId = jsApiParameters.wx_app_id
                    const that = this
                    wx.navigateToMiniProgram({
                      appId: jsApiParameters.wx_app_id,
                      path: jsApiParameters.miniapp_path,
                      success(res) {
                        // 打开成功
                        // console.log(res)
                      },
                      fail(error) {
                        // this.$Error('跳转失败')
                        that.Jump('/order-lists')
                      }
                    })
                  } else if (small.wxCache('adapayPlugVersion') == 'self') {
                    smllpay.wxOrderPay(res.data.jsApiParameters)
                  } else {
                    const adapayPlugin = small.wxCache('adapayPlugVersion') == 'new' ? requirePlugin("Adapay") : requirePlugin("adapay-plugin")
                    // 汇付分账
                    const hfPay= res.data.jsApiParameters
                    if (hfPay) {
                      adapayPlugin.requestPay(hfPay, this.paySuccess, this.payError);
                    }
                  }
                }
              } else if (res.data && res.data.url) {
                openPage(res.data.url)
              }
              // window.location.href = res.data.url
            } else {
              this.$Error(res.msg)
            }
          })
        }
      } else {
        if (money_type == 2 && popup_show) {
          this.showPwd = true
        } else {
          const params = { hantepay: hantepay, global_alipay_currency: global_alipay_currency, pay_type: payType, order_id: order_id, money_type: money_type, payment_type: payment_type, tlfz_pay_type: tlfz_pay_type }
          this.$loadingWrap.show()
          /* setTimeout(() => {
            this.$loadingWrap.close()
          }, 10000) */
          if (payType == 34) {
            params.adapay_pay_type = submitData.adapay_pay_type
          }
          payUrl(params).then(res => {
            this.$loadingWrap.close()
            if (res.status == 1) {
              // TODO 小程序支付处理
              if (res.data && res.data.jsApiParameters) {
                if (payType == 2 || payType == 19 || (payType == 26 && !res.data.is_mini_vsp) || payType == 29 || payType == 48) {
                  smllpay.wxOrderPay(res.data.jsApiParameters)
                } else if (payType == 26 && res.data.is_mini_vsp) {
                  this.Jump('/buyTonglianWait',{ order_id, pay_type: 1 })
                } else if (payType == 34) {
                  if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
                    const jsApiParameters = typeof res.data.jsApiParameters == 'object' ? res.data.jsApiParameters: JSON.parse(res.data.jsApiParameters)
                    this.hfAppId = jsApiParameters.wx_app_id
                    const that = this
                    wx.navigateToMiniProgram({
                      appId: jsApiParameters.wx_app_id,
                      path: jsApiParameters.miniapp_path,
                      success(res) {
                        // 打开成功
                        // console.log(res)
                      },
                      fail(error) {
                        // this.$Error('跳转失败')
                        that.Jump('/order-lists')
                      }
                    })
                  } else if (small.wxCache('adapayPlugVersion') == 'self') {
                    smllpay.wxOrderPay(res.data.jsApiParameters)
                  } else {
                    const adapayPlugin = small.wxCache('adapayPlugVersion') == 'new' ? requirePlugin("Adapay") : requirePlugin("adapay-plugin")
                    // 汇付分账
                    const hfPay= res.data.jsApiParameters
                    if (hfPay) {
                      adapayPlugin.requestPay(hfPay, this.paySuccess, this.payError);
                    }
                  }
                }
              } else if (res.data && res.data.url) {
                openPage(res.data.url)
              }
              // window.location.href = res.data.url
            } else {
              this.$Error(res.msg)
            }
          })
        }
      }
    },
    // 输入支付密码点击确定
    payPwdCallback() {
      const submitData = this.submitData
      const payType = submitData.type
      const order_id = submitData.order_id
      const money_type = submitData.moneyType
      const payment_type = submitData.payment_type
      const global_alipay_currency = submitData.global_alipay_currency
      const hantepay = submitData.hantepay
      const tlfz_pay_type = submitData.tlfz_pay_type
      const params = { hantepay: hantepay, global_alipay_currency: global_alipay_currency, pay_type: payType, order_id: order_id, money_type: money_type, payment_type: payment_type, tlfz_pay_type: tlfz_pay_type }
      this.$loadingWrap.show()
      /* setTimeout(() => {
        this.$loadingWrap.close()
      }, 10000) */
      if (payType == 34) {
        params.adapay_pay_type = submitData.adapay_pay_type
      }
      payUrl(params).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          // TODO 小程序支付处理
          if (res.data && res.data.jsApiParameters) {
            if (payType == 2 || payType == 19 || payType == 26 || payType == 48) {
              smllpay.wxOrderPay(res.data.jsApiParameters)
            } else if (payType == 34) {
              if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
                const jsApiParameters = typeof res.data.jsApiParameters == 'object' ? res.data.jsApiParameters: JSON.parse(res.data.jsApiParameters)
                this.hfAppId = jsApiParameters.wx_app_id
                const that = this
                wx.navigateToMiniProgram({
                  appId: jsApiParameters.wx_app_id,
                  path: jsApiParameters.miniapp_path,
                  success(res) {
                    // 打开成功
                    // console.log(res)
                  },
                  fail(error) {
                    // this.$Error('跳转失败')
                    that.Jump('/order-lists')
                  }
                })
              } else if (small.wxCache('adapayPlugVersion') == 'self') {
                smllpay.wxOrderPay(res.data.jsApiParameters)
              } else {
                const adapayPlugin = small.wxCache('adapayPlugVersion') == 'new' ? requirePlugin("Adapay") : requirePlugin("adapay-plugin")
                // 汇付分账
                const hfPay= res.data.jsApiParameters
                if (hfPay) {
                  adapayPlugin.requestPay(hfPay, this.paySuccess, this.payError);
                }
              }
            }
          } else if (res.data && res.data.url) {
            openPage(res.data.url)
          }
          // window.location.href = res.data.url
        } else {
          this.$Error(res.msg)
        }
      })
    },
    // 关闭输入支付密码弹窗
    closePwd() {
      this.showPwd = false
    },
    // 汇付支付成功
    paySuccess() {
      this.closePayPop()
      this.$Error('支付成功！')
      setTimeout(() => {
        this.Jump('/order-lists',{type:6})
      }, 1000)
    },
    // 汇付支付失败
    payError() {
      this.closePayPop()
      this.$Error('支付失败！')
      setTimeout(() => {
        this.Jump('/order-lists',{type:2})
      }, 1000)
    }
  },
  mounted() {
    const resData=this.detailAll
    // 如果为抽奖团并且剩余拼团数大于0 则不显示退款按钮
    if (resData.aggregation_type && resData.aggregation_type == 3 && resData.groupBuy_left && resData.groupBuy_left > 0 ) {
      this.isPrizeGroup = false
    }
    this.payPopData.balance = resData.balance
    this.payPopData.is_dhs_allow_deposit = resData.is_dhs_allow_deposit
    this.payPopData.is_check_dhs = resData.is_check_dhs
    this.payPopData.dhs_deposit = resData.dhs_deposit
    this.payPopData.deposit_alias = resData.deposit_alias
    this.payPopData.is_open_balance_pay = resData.is_open_balance_pay // 是否开启余额支付
    // 预存款 - 实付款 判断是否开启预存款 混合支付
    this.payPopData.yckMargin = resData.scym_yck_money - resData.detail.payment
    this.payPopData.scym_yck_dz = resData.scym_yck_dz
    this.payPopData.scym_yck_money = resData.scym_yck_money
    // 是否预存款支付
    this.payPopData.is_advance_deposit_pay = resData.is_advance_deposit_pay
    if (resData.detail.item) {
      resData.detail.item.forEach((item) => {
        if (item.list) {
          item.list.forEach((goods) => {
            if(goods.item_id) {
              this.itemIds.push(goods.item_id)
            }
          })
        }
      })
    }
    // console.log(this.itemIds, 'this.itemIds')

    if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
      window.addEventListener('wxshow', () => {
        let options = wx.getEnterOptionsSync();
        // wx1e18d140f890f2c5，wx308088053f4ecc3a
        if (options.scene == '1038' && options.referrerInfo.appId == this.hfAppId && this.remark == 2) {
          // 代表从收银台小程序返回
          this.Jump('/order-lists')
        }
      }),
      window.addEventListener('wxHide', () => {
        this.remark = 2
      })
    }
    if (this.$route.query.edit == 1) {
      if (resData.detail.client_edit_order_address && resData.detail.client_edit_order_address != 0) {
        this.handleClickOpenAddress()
      } else {
        this.$Error('改地址申请商家审核中')
      }
    }
  },
  created() {
    if (small.wxCache('adapayPlugVersion') == 'jump_adapay_mini') {
      this.remark = 1
    }
  },
  computed: {
    detail() {
      return this.detailAll.detail
    },
    is_wx() {
      return isWeixinCient()
    },
    Tel() {
      return this.detailAll.after_sale_tel
        ? `tel:${this.detailAll.after_sale_tel}`
        : 'javascript:;'
    }
  }
})
</script>

<style lang="scss">
@import "src/styles/variables.scss";
@import "src/styles/mixin";
.actions{
  padding-bottom:100px;
}
.bottom-btn{
  position:fixed;
  left:0;
  bottom:0;
  width:100%;
  // height:98px;
  padding:14px 16px;
  font-size:0;
  background:#fff;
  text-align:right;
  z-index: 99;
  box-sizing: border-box;
  .inline-block{
    display:inline-block;
  }
  .btn{
    width:166px;
    height:72px;
    margin:6px;
    font-size:28px;
    color:#fff;
    background:linear-gradient(-90deg,rgba(233,1,4,1),rgba(254,27,73,1));
    &.no-border{
      border:0;
    }
    &.border {
      border: 1px solid #ffaf4f;
      background: #fff;
      color: #ffaf4f;
    }
    &.refunding-btn{
      border-color:#B3B3B3;
      color:#666666;
      background:#fff;
      border: 1px solid #B3B3B3;
      img{
        width: 24px;
        height: 24px;
        margin-right: 12px;
      }
    }
    &.share-price{
      background:linear-gradient(90deg,rgba(255,174,0,1),rgba(255,138,2,1));
    }
  }
}
.donation-box{
  .title {
    font-size: 35px;
    color: #333;
    font-weight: 600;
    text-align: center;
    margin-bottom: 40px;
  }
  .con-box{
    position:relative;
    padding:40px 60px;
  }
  .input-box{
    margin:16px 0;
    font-size:28px;
    label{
      float:left;
      display:block;
      width:150px;
      line-height:76px;
      text-align:right;
      font-weight:normal;
      color: #666666;
    }
    input{
      float:left;
      -webkit-appearance: none;
      width:256px;
      height:76px;
      padding:16px 10px;
      border:2px solid #EDEDED;
      border-radius:6px;
    }
  }
  .tongMsg {
    text-align: center;
    margin-top: 16px;
    font-size: 26px;
  }
  .tongTips {
    text-align: center;
    margin: 20px 0;
    font-size: 26px;

  }
}
</style>
